<?php
class ToolTipHelper extends Helper {
	var $helpers=array('Text','Form','Html');

	function truncate($textStr,$length){
		if(strlen($textStr)<=$length){
			return $this->output("<span>$textStr</span>");
		}else{
			if(strlen($textStr)>70){
				$isShowWidth=true;
			}else{
				$isShowWidth=false;
			}
			$strFilter = preg_replace("/\n|\r|\'|\\\|\"/","",$textStr);
			$strTruncate = $this->Text->truncate($textStr,$length);
			return $this->output("<span onmouseover=\"showToolTip('$strFilter',event,'$isShowWidth')\" onmouseout=\"hideToolTip();\">$strTruncate</span>");
		}
	}
	function truncateForJs($textStr,$length){
		if(strlen($textStr)<=$length){
			return $this->output("<span>$textStr</span>");
		}else{
			if(strlen($textStr)>70){
				$isShowWidth=true;
			}else{
				$isShowWidth=false;
			}
			$strFilter = preg_replace("/\n|\r|\'|\\\|\"/","",$textStr);
			$strTruncate = $this->Text->truncate($textStr,$length);
			return $this->output("<span onmouseover=\"showToolTip(\'$strFilter\',event,\'$isShowWidth\')\" onmouseout=\"hideToolTip();\">$strTruncate</span>");
		}
	}	
	
	function truncateForImgTooltip($textStr){
		
		if($textStr == null){
			return $this->output("");
		}
		
		$strFilter = preg_replace("/\n|\r|\'|\\\|\"/","",$textStr);
		
		return $this->output("$strFilter");

	}	
}
?>
